<html>
<head>
<title>JW API Example 5-2-1-0 - JW FLV Media Player</title>

<script type="text/javascript" src="http://localhost/carbonpa-dev/wp-content/plugins/proplayer/js/swfobject.js"></script>
<?php
	print insert_proplayer(
	     array(
	        "width" => "620",
	        "height" => "465",
//	        "autostart" =>"true",
//	        "repeat" => "true",
//	        "image" => "http://localhost/carbonpa-dev/le-grand-mix/2011/03/21/mon-premier-mix-2"
//	        "skin" => "http://isagoksu.com/wp-content/plugins/proplayer/players/skins/default.swf"
	     ),
	     "http://player.vimeo.com/video/16962056"
	); 	
?>
<script>
var player = null;
function playerReady(thePlayer) {
    player = window.document[thePlayer.id];
}
playerReady('pro-player-pp-single-4d94606c11e37');
</script>

<a href="#" onclick="player.sendEvent('STOP');
    player.sendEvent('LOAD', 
    'http://www.dailymotion.com/video/xekogb_usher-pitbull-dj-got-us-fallin-in-l_music');
    ">Load Video Dailymotion</a>
<br>

<a href="#" onclick="player.sendEvent('STOP');
    player.sendEvent('LOAD', 
    'http://www.youtube.com/watch?v=OYpeAnSxI5s&feature=related');
    ">Load Video Youtube</a>
<br>

<a href="#" onclick="player.sendEvent('STOP');
    player.sendEvent('LOAD', 
    'http://vimeo.com/10948884');
    ">Load Video Vimeo</a>
<br>

<?php

//Single Dailymotion  video with the JW player
//EXAMPLE
//http://www.dailymotion.com/video/x2q0rp_amy-winehouse-stronger-than-me_music
//$videocode will be x2q0rp_amy-winehouse-stronger-than-me_music or use just this code x2q0rp
    $videocode = 'x2q0rp_amy-winehouse-stronger-than-me_music';


    // set video data feed URL
    $feedURL = 'http://www.dailymotion.com/atom/video/' . $videocode;


    // read feed into SimpleXML object
	if(!$sxml = @simplexml_load_file($feedURL))
	{
	  echo '<div style="width:470px; height:320px;border: 1px solid #000;">No connection to the Dailymotion server or a wrong url !</div>';
	  return;
	}


    // Find out the link to the first FLV
    $linksurl = $sxml->entry->children('http://www.w3.org/2005/Atom');


    $linkproperties = array('enclosure');
    foreach($linkproperties as $content){
        $$content = null;
        $exit = false;
        foreach($linksurl as $links) {
            if($exit){
                continue;
            }
            foreach($links->attributes() as $keys => $values) {
                if($keys == 'href'){
                    $$content = (string) $values;
                }
                if (stristr ($values , $content) == TRUE) {
                    $exit = true;
                }


            }
        }
        if(!$exit){
            $$content = null;
        }
    }
?>


<div id="player">This text will be replaced</div>


<script type="text/javascript">


var so = new SWFObject('http://www.longtailvideo.com/jw/embed/player.swf','mpl','470','320','9');
so.addParam('allowscriptaccess','always');
so.addParam('allowfullscreen','true');
so.addParam('flashvars','&file=<?=$enclosure; ?>&autostart=true&stretching=fill');
so.write('player');
</script>
